<template>
                <a-tree-select
                        treeDataSimpleMode
                        :treeDefaultExpandAll="treeDefaultExpandAll"
                        :placeholder="placeholder"
                        v-model="deptSelect"
                        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                        :tree-data="treeData"
                        allowClear
                        @change="onchange"
                />
</template>
<script>
        import {simpleTree} from "../../../util/internal.api";
        export default {
                props: ['value'],
                data() {
                        return {
                                deptSelect:null,
                                treeDefaultExpandAll:true,
                                placeholder:"请选择部门",
                                treeExpandedKeys: [],
                                treeData: [], //部门树
                                replaceFields:{id:"code" ,pid:"parentCode",key:"id",value:"code",title:"name"}
                        };
                },
                methods:{
                        onchange(value){
                                this.$emit('deptSelectResult',value);
                        },
                        getDeptTree(){
                                simpleTree().then(res => {
                                        if (res.code === 0) {
                                                this.treeData = res.data.result;
                                        }
                                })
                        }
                },
                //初始化部门树
                created() {
                        this.getDeptTree();
                          this.deptSelect=this.value;
                },
                watch:{
                        value(val){
                                this.deptSelect=val;
                        }
                }
        };
</script>
